<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<!--<div class="layuimini-container">-->
<div class="layuimini-main">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-xs12">
            <fieldset class="table-search-fieldset">
                <div id="echarts-dataset" style="background-color:#ffffff;min-height:600px;padding: 10px"></div>
            </fieldset>
        </div>
    </div>


</div>
<!--</div>-->
{include file="public/footer" /}
<script>
    layui.use(['layer', 'echarts'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            echarts = layui.echarts;
        /**
         * 柱状图
         */
        var echartsDataset = echarts.init(document.getElementById('echarts-dataset'), 'walden');

        var optionDataset = {
            title: {
                text: '赠送金币',
                textStyle: {
                    color: 'red'
                },
                padding: [0, 0, 10, 100]  // 位置
            },
            legend: {
                type: 'plain',  // 图列类型，默认为 'plain'
                top: '1%',  // 图列相对容器的位置 top\bottom\left\right
            },
            tooltip: {
                trigger: 'item',
                formatter: function (params) {
                    if ("{$countNum}" != 0) {
                        return params.name + "<br />" +
                            '数量：' + params.data + "<br />" +
                            '占比：' + ((parseInt(params.data) / parseInt("{$countNum}")) * 100).toFixed(2) + '%';
                    }
                }
            },
            xAxis: {
                type: 'category',
                axisLabel: {
                    formatter : function(params,val){
                        let x = [{$data}][val]
                        if(x==undefined || x=='undefined'){
                            x=0;
                        }
                        return params.replace('&middot;','.')+"\n\n数量:"+x+"\n占比:"+((parseInt(x) / parseInt("{$countNum}")) * 100).toFixed(2) + '%';
                    }
                },
                data: ['转轮', '兑换', '任务', '签到', '答题', '系统赠送']
            },
            yAxis: {
                type: 'value',
            },
            series: [
                {
                    type: 'bar',
                    data: [{$data}],
                },
            ]
        };
        echartsDataset.setOption(optionDataset);

        // echarts 窗口缩放自适应
        window.onresize = function () {
            echartsDataset.resize();
        }

    });
</script>
</body>
</html>
